/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */

#ifndef __GB_SCENE_WINDOW_H__
#define __GB_SCENE_WINDOW_H__

#include <QtCore/QTimer>
#include <QtGui/QApplication>
#include <QtGui/QWidget>

#include "GameBuilder.h"

namespace PQBuilder
{
	//used to build game scene
	//should have a game render window for test game running
	class SceneWindow : 
		public QWidget
	{
	public:
		SceneWindow(QWidget *parent=0,Qt::WindowFlags flag=0);
		virtual ~SceneWindow();
		
		void updateScene(float deltaT);
		void activeScene();

		void setTimer();
		void timerEvent(QTimerEvent *evt);
		QPaintEngine* paintEngine() const;
		
	protected:
		void paintEvent(QPaintEvent* evt);

		void keyPressEvent(QKeyEvent *evt);
		void keyReleaseEvent(QKeyEvent *evt);
		void mouseMoveEvent(QMouseEvent *evt);
		void mousePressEvent(QMouseEvent *evt);
		void mouseReleaseEvent(QMouseEvent *evt);

		void resizeEvent(QResizeEvent* evt);
		void focusOutEvent(QFocusEvent *evt);
		void focusInEvent(QFocusEvent *evt);

		void leaveEvent(QEvent *evt);
		void wheelEvent(QWheelEvent *evt);
		void dragEnterEvent(QDragEnterEvent *evt);
		void dragLeaveEvent(QDragLeaveEvent *evt);
		void dragMoveEvent(QDragMoveEvent *evt);
		void dropEvent(QDropEvent *evt);
	
		//Implent PQEngine::GEventListener,obselete
		void OnCreateObject(PQEngine::ObjectType type,int x,int y);
		void OnAddResource(std::string path,int x,int y);
	private:
		unsigned int _lastTime;
		float _frameRate;
		bool _inited;

	};
}
#endif
